<?php 
	class BlogRelationModel extends RelationModel{
		protected $tableName='blog';
		protected $_link=array(
			'attr'=>array(
				'mapping_type'=>MANY_TO_MANY,
				'foreign_key'=>'bid',
				'relation_foreign_key'=>'aid',
				'relation_table'=>'blog_attr'
				),
			'cate'=>array(
				'mapping_type'=>BELONGS_TO,
				'foreign_key' =>'cid',
				'mapping_fields'=>'id,name',
				)
			);
		public function getBlogs($limit,$type= 0){
			$field=array('content','del');
			$where=array('del'=>$type);
			return D('BlogRelation')->where($where)->field($field,true)->limit($limit)->relation(true)->order('time DESC')->select();
		}
		public function getBlog($id){
			return D('BlogRelation')->relation(true)->find($id);
		}
	}